#include "movietooltip.h"

#include <QLabel>
#include <QGridLayout>
#include <QStyle>

#include "movielabel.h"
#include <kdclib.h>
#include <KHBox>
#include <KVBox>

MovieToolTip::MovieToolTip( KDCMovie *aMovie, const QPixmap &aPixmap, QWidget *aParent ) : QWidget( aParent )
{
	MovieLabel *fMovieLabel = new MovieLabel( this );
	fMovieLabel->setMovie( aMovie );
	
	QLabel *icon = new QLabel( this );
    icon->setPixmap( style()->standardIcon( QStyle::SP_MessageBoxInformation ).pixmap( 28, 28 ) );
    icon->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
    icon->installEventFilter( this );

    QLabel *fTitle = new QLabel( aMovie->outputName(), this );
    fTitle->setTextFormat( Qt::RichText );
    QFont font;
    font.setPointSize( 12 );
    fTitle->setFont( font );
    QPalette palette( fTitle->palette() );
    palette.setColor( QPalette::Foreground, QColor( 0, 64, 128 ) );
    fTitle->setPalette( palette );

	KVBox *fMessage = new KVBox( this );
    new QLabel( aMovie->metaData()->name(), fMessage );
	for ( int i=0; i<aMovie->subMovies().size(); ++i )
		new QLabel( aMovie->subMovies().at( i )->metaData()->name(), fMessage );

	KHBox *box = new KHBox( this );
	QLabel *pix = new QLabel( box );
	pix->setPixmap( aPixmap );
	fMovieLabel->setParent( box );
	
    QGridLayout *mainLayout = new QGridLayout( this );
    mainLayout->addWidget( icon, 0, 0 );
    mainLayout->addWidget( fTitle, 0, 1 );
    mainLayout->addWidget( fMessage, 1, 1, 1, 2 );
	mainLayout->addWidget( box, 2, 0, 1, 2 );

    mainLayout->setSizeConstraint( QLayout::SetFixedSize );
    mainLayout->setContentsMargins( 15, 10, 15, 10 );
}

